package mylibrary.socket;

import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class Client {

	public static void main(String[] args) throws Exception {
		
		//Socket socket = new Socket("localhost", 100);
		Socket socket = new Socket("192.168.205.82", 100);
		
		//ObjectOutputStream outputStream = new ObjectOutputStream(socket.getOutputStream());  会有乱码  文件转换有问题
		DataOutputStream outputStream = new DataOutputStream(socket.getOutputStream());
		
		
		FileInputStream in = new FileInputStream("D:\\Study\\EJB.txt");
		
		byte[] b = new byte[1024];
		int noOfBytes = 0;
		
		while ((noOfBytes = in.read(b)) != -1) {
			outputStream.write(b, 0, noOfBytes);
		}
		
		outputStream.flush();
		outputStream.close();
		
		in.close();
		
		socket.close();
	}
}
